#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n = 0; int arr[6][6];
	while (scanf("%d", &n) == 1)
	{
		int i, j;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				scanf("%d", &arr[i][j]);
			}
		}
		int m = 0;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (i > j)
				{
					if (arr[i][j] != 0)
					{
						printf("NO\n"); m++; break;
					}
				}
			}
			if (m != 0)
			{
				break;
			}
		}
		if (m == 0)
		{
			printf("YES\n");
		}
	}

	return 0;
}